home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 6.4 KB | 259 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: HelloPrt.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Hello.hpp"
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- #ifndef BINDING_K
- #include "Binding.k"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef SELECT_H
- #include "Select.h"
- #endif
-
- // ----- Framework Layer -----
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWMENU_H
- #include "FWMenu.h"
- #endif
-
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h"
- #endif
-
- #ifndef FWRESTYP_H
- #include "FWResTyp.h"
- #endif
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWBARRAY_H
- #include "FWBArray.h"
- #endif
-
- #ifndef FWABOUT_H
- #include "FWAbout.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- #ifndef FWSTRS_H
- #include "FWStrs.h"
- #endif
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_ODTranslation_xh
- #include <Translt.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- //========================================================================================
- // Constants and Globals
- //========================================================================================
-
- #define kMainPresentation "ODFExamples:Presentation:ODFHello"
-
- //========================================================================================
- // Runtime info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfhello
- #endif
-
- FW_DEFINE_AUTO(CHelloPart)
-
- //========================================================================================
- // CHelloPart class
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CHelloPart constructor
- //----------------------------------------------------------------------------------------
-
- CHelloPart::CHelloPart(ODPart* odPart) :
- FW_CPart(odPart, FW_gInstance, kPartInfoID),
- fPartContent(NULL),
- fPresentation(NULL)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloPart destructor
- //----------------------------------------------------------------------------------------
-
- CHelloPart::~CHelloPart()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloPart::Initialize
- //----------------------------------------------------------------------------------------
-
- void CHelloPart::Initialize(Environment* ev, ODStorageUnit* storageUnit, FW_Boolean fromStorage)
- {
- FW_CPart::Initialize(ev, storageUnit, fromStorage);
-
- // ----- Register our Presentation
- fPresentation = RegisterPresentation(ev, kMainPresentation, TRUE, FW_NEW(CHelloSelection, (ev, fPartContent)));
-
- // ----- Register our other kinds -----
- RegisterKind(ev, 'TEXT', kODPlatformDataType, FW_kAllStorage, FW_kImportExportEnabled);
- RegisterKind(ev, 'TEXT', kODPlatformFileType, FW_kDataInterchangeStorage, FW_kImport);
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloPart::NewFrame
- //----------------------------------------------------------------------------------------
-
- FW_CFrame* CHelloPart::NewFrame(Environment* ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_Boolean fromStorage) // Override
- {
- FW_UNUSED(fromStorage);
-
- return FW_NEW(CHelloFrame, (ev, odFrame, presentation, fPartContent));
- }
-
- //------------------------------------------------------------------------------
- // CHelloPart::NewPartContent
- //------------------------------------------------------------------------------
-
- FW_CContent* CHelloPart::NewPartContent(Environment* ev)
- {
- fPartContent = FW_NEW(CHelloContent, (ev, this));
- return fPartContent;
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloPart::DoMenu
- //----------------------------------------------------------------------------------------
-
- FW_Handled CHelloPart::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent) // Override
- {
- FW_Handled menuHandled = FW_kHandled;
- ODCommandID id = theMenuEvent.GetCommandID(ev);
-
- switch (id)
- {
- case cPlaceInCenter:
- fPartContent->CenterText(ev, TRUE);
- break;
-
- case cPlaceAtTop:
- fPartContent->CenterText(ev, FALSE);
- break;
-
- default:
- menuHandled = FW_kNotHandled;
- }
-
- return menuHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloPart::DoAbout
- //----------------------------------------------------------------------------------------
-
- FW_Handled CHelloPart::DoAbout(Environment* ev)
- {
- ::FW_About(ev, this, kAbout);
-
- return FW_kHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloPart::DoAdjustMenus
- //----------------------------------------------------------------------------------------
-
- FW_Handled CHelloPart::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus,
- FW_Boolean isRoot)
- {
- FW_UNUSED(isRoot);
- if (hasMenuFocus)
- {
- // ----- Set up the Hello menu
- menuBar->EnableAndCheckCommand(ev, cPlaceInCenter, TRUE, fPartContent->IsTextCentered());
- menuBar->EnableAndCheckCommand(ev, cPlaceAtTop, TRUE, !fPartContent->IsTextCentered());
- }
-
- return FW_kNotHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CHelloPart::PartChanged
- //----------------------------------------------------------------------------------------
-
- void CHelloPart::PartChanged(Environment* ev, FW_Boolean invalidateOnly)
- {
- if (!invalidateOnly)
- {
- // Mark the document's draft as changed so it can be saved
- this->Changed(ev);
-
- // Mark the display frame as changed, so that containing parts can update links
- fPresentation->ContentUpdated(ev);
- }
-
- // Force all display frames to be redrawn
- fPresentation->Invalidate(ev);
- }
-